/*
 * @Author: your name
 * @Date: 2021-07-10 14:15:50
 * @LastEditTime: 2021-07-10 14:55:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \lxy\main.cpp
 */
#include <iostream>
#include <unordered_map>
#include<vector>
using namespace std ;

int main(int, char**) {
    unordered_map<int,vector<string> > strmap;
    string input="" ;
    cin>>input;
    int maxlength=0;
    while(input!="#")
    {
        int length=0;
        for (int j = 0;j<input.size();++j)
        {
            if(input[j]=='e')
                length++;
        }
        if(length>maxlength)
        maxlength=length;

        if(!strmap.count(length))
        {
            vector<string> temp={input};
            strmap.insert(make_pair(length,temp));
        }
        else 
        {
            strmap.find(length)->second.push_back(input);
        }
        cin>>input;
    }
    for(auto i : strmap.find(maxlength)->second)
    {
        cout << i<<endl;
    }

}
